import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

part './entry_add_state.dart';

class EntryAddCubit extends Cubit<EntryAddState> {
  EntryAddCubit() : super(EntryAddState(name: "", richText: "", tags: []));

  addTags(String value) {
    state.tags.add(value);
    emit(state.clone(state));
  }

  void updateName(String text) {
    state.name = text;
    emit(state.clone(state));
  }

  void updateRichText(String text) {
    state.richText = text;
    emit(state.clone(state));
  }

  void submit(BuildContext context) {
    debugPrint(state.name);
    debugPrint(state.richText);
    debugPrint(state.tags.toString());
  }
}
